{include file="common/head"/}
<style>
    .dayAll span.box{
        padding: 7px;
        display: block;
        width: 100px;
        float: left;
    }
    .liang .layui-form-checkbox[lay-skin=primary] span {color:#5fb878}
    .hui .layui-form-checkbox[lay-skin=primary] span{color:#ddd}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <!--layui-this-->
            {volist name='month.month' id='v'}
                {if $onMonth == $key}
                    <li class="layui-this">{$v}</li>
                {else/}
                    <li class="">{$v}</li>
                {/if}

            {/volist}

        </ul>
        <div class="layui-tab-content">
            <!--layui-show-->
            {volist name='month.month_day' id='v' key='k1'}
                {if $onMonth == $key}
                    <div class="layui-tab-item layui-show">
                    {else/}
                    <div class="layui-tab-item">
                {/if}
                <form class="layui-form layui-form-pane"  onsubmit="false" id="ckbox">
                    <!--小于已过月份,大于当前一个月禁用-->
                    {if ($key < $onMonth) or ($key > $onMonth+1) }
                        <div class="layui-form-item">超过当前月份不可选择!</div>
                        <div class="layui-input-inline dayAll">
                            {volist name='v' id='v1'}
                                 <span class="box hui"><input type="checkbox" name="mark[{$v1}]" lay-skin="primary" title="{$v1}" disabled=""></span>
                            {/volist}
                        </div>
                    {else/}
                        <div class="layui-form-item">超过当前日期的不可选择!</div>
                        <div class="layui-input-inline dayAll">
                            {volist name='v' id='v1' key='k'}
                                {php} $days = $year.'-'.addZero($k1).'-'.addZero($k);{/php}<!--组装一下日期-->
                                <!--当前月的下一个月开启-->
                                {if $k1 == $onMonth+2}
                                    <!--判断是否已经选择-->
                                    {in name="$days" value="$timeDate"}
                                        <span class="box liang"><input type="checkbox" checked  name="mark" value="{$year}-{$k1|addZero}-{$k|addZero}" lay-skin="primary" title="{$v1}" ></span>
                                    {else/}
                                        <span class="box liang"><input type="checkbox" name="mark" value="{$year}-{$k1|addZero}-{$k|addZero}" lay-skin="primary" title="{$v1}" ></span>
                                    {/in}
                                {else/}
                                    <!--本月已过日期禁用-->
                                    {if ($k-1 <= $onDay)}
                                        <span class="box hui"><input type="checkbox" name="mark" value="{$year}-{$k1|addZero}-{$k|addZero}" lay-skin="primary" title="{$v1}" disabled=""></span>
                                    {else/}
                                        <!--判断是否已经选择-->
                                        {in name="$days" value="$timeDate"}
                                        <span class="box liang"><input type="checkbox" checked  name="mark" value="{$year}-{$k1|addZero}-{$k|addZero}" lay-skin="primary" title="{$v1}" ></span>
                                        {else/}
                                        <span class="box liang"><input type="checkbox" name="mark" value="{$year}-{$k1|addZero}-{$k|addZero}" lay-skin="primary" title="{$v1}" ></span>
                                        {/in}
                                    {/if}
                                {/if}
                            {/volist}
                        </div>
                    {/if}

                    <div style="padding: 8px;"></div>
                    <div class="layui-form-item">
                        <div class="layui-btn" id="submits">提交选择</div>
                    </div>
                    <!--<div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="date"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="number" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">开班人数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="title" autocomplete="off" placeholder="" class="layui-input">
                        </div>
                    </div>-->
                </form>
            </div>
            {/volist}
        </div>
    </div>

   <!-- <p><span>选择月份添加 : </span></p>
    <div class="month">
        {volist  name='month.month' id = 'v' }
        <button class="layui-btn layui-btn-primary" data-m="{$key}">{$v}</button>
        {/volist}
    </div>
    <form class="layui-form ">
        <div class="layui-form-item"> </div>
        <div class="layui-form-item">每月的哪一天？以下选项可以多选</div>
        <div class="layui-input-inline dayAll">
            <span class="box"><input type="checkbox" name="mark[1]" lay-skin="primary" title="1号"></span>
        </div>
    </form>-->
</div>
{include file="common/foot"/}
    <script>
        layui.use(['form', 'layer','element'], function () {
            var form = layui.form, $ = layui.jquery,element = layui.elemen;

            form.on('submit(submit)', function (data) {
                // 提交到方法 默认为本身
                data.field.ad_id = $scope.field.ad_id;
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("", data.field, function (res) {
                    layer.close(loading);
                    if (res.code > 0) {
                        layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                            location.href = res.url;
                        });
                    } else {
                        layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                });
            });

            //获取发布日期返回给父窗口
            $('.layui-tab #submits').click(function(){
                var data=[];
                $("input:checkbox[name='mark']:checked").each(function() { // 遍历name=standard的多选框
                    data.push($(this).val());  //将日期追加入数组
                });

                //将组装完成的数组返回给 父窗口处理
                window.parent.setTbale(data);//访问父页面方法

                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);//关闭弹出的子页面窗口

            });


            $(".catMin a").on("click",function(){
                var cid = $(this).attr('data-id');
                var name = $(this).attr('data-name');

                window.parent.document.getElementById("getCat").value = name;
                window.parent.document.getElementById("getCatid").value = cid;

                //关闭当前窗口
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);

            });
        });
    </script>